package com.example.mapper;

import com.example.annotation.PublicAutoFill;
import com.example.enumeration.OperationType;
import com.github.pagehelper.Page;
import com.pojo.dto.QueryPageDTO;
import com.pojo.entity.Dish;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface DishMapper {

    @Select("select count(*) from dish where category_id = #{id}")
    Integer countByCategoryById (Long id);


    @PublicAutoFill(OperationType.INSERT)
    @Insert("insert into dish(name,category_id,price,image,description,status,create_time,update_time,create_user,update_user) " +
            "values (#{name},#{categoryId},#{price},#{image},#{description},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Dish dish);



    Page<Dish> page(QueryPageDTO queryPageDTO);

    Long getDishByName(String name);

    void deleteArr(@Param("ids") Long[] ids);

    @Select("select * from dish where id = #{id}")
    Dish getDishById(@Param("id") Long id);

    @PublicAutoFill(OperationType.UPDATE)
    void update(Dish dish);
}
